//
//  ZWPaddingLabel.m
//  BTShike2
//
//  Created by ZDTX on 2021/1/22.
//  Copyright © 2021 刘军林. All rights reserved.
//

#import "ZWPaddingLabel.h"
#import "UIColor+Hex.h"
@interface ZWPaddingLabel()


@end
@implementation ZWPaddingLabel


-(instancetype) init{
    if (self = [super init]) {
//        self.layer.cornerRadius = 5.0f;
//        self.layer.masksToBounds = YES;
//        self.font = [UIFont systemFontOfSize:10.f];
//        self.backgroundColor = [UIColor colorWithHexString:@"#4185F4" alpha:1.0];
//        self.textColor = [UIColor colorWithHexString:@"#FFFFFF" alpha:1.0];
    }
    return self;
}

- (CGRect)textRectForBounds:(CGRect)bounds limitedToNumberOfLines:(NSInteger)numberOfLines {
    UIEdgeInsets insets = self.edgeInsets;
    CGRect rect = [super textRectForBounds:UIEdgeInsetsInsetRect(bounds, insets)
                    limitedToNumberOfLines:numberOfLines];
    
    rect.origin.x    -= insets.left;
    rect.origin.y    -= insets.top;
    rect.size.width  += (insets.left + insets.right);
    rect.size.height += (insets.top + insets.bottom);
    
    return rect;
}

- (void)drawTextInRect:(CGRect)rect {
    [super drawTextInRect:UIEdgeInsetsInsetRect(rect, self.edgeInsets)];
}


//// Only override drawRect: if you perform custom drawing.
//// An empty implementation adversely affects performance during animation.
//- (void)drawRect:(CGRect)rect {
//    // Drawing code
//
//
//}


@end
